package com.example.demo.controller;

import com.example.demo.service.GenService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class GenController {
    private static final Logger log = LoggerFactory.getLogger(GenController.class);

    @Autowired
    GenService genService;

    @GetMapping("/genCode1")
    @ResponseBody
    public String genCode1(String name) {
        // 获取模板文件
        String result = genService.generatorCode(
                "vm/html.vm",
                "/tmp/vm",
                "out1.html"
        );
        return result;
    }


    @GetMapping("/genCode2")
    @ResponseBody
    public String genCode2(String name) {
        // 获取模板文件
        String result = genService.generatorCode(
                "vm/tmpFile.vm",
                "/tmp/vm",
                "out2.txt"
        );
        return result;
    }

    @GetMapping("/genCode3")
    @ResponseBody
    public String genCode3(String name) {
        // 获取模板文件
        String result = genService.generatorCode(
                "vm/test.vm",
                "/tmp/vm",
                "test.txt"
        );
        return result;
    }
}
